Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
retext-visit
Advanced tools
retext node visitor.
npm:
$ npm install retext-visit
$ component install wooorm/retext-visit
$ bower install retext-visit
Duo:
var visit = require('wooorm/retext-visit');
var Retext = require('retext');
var visit = require('retext-visit');
var inspect = require('retext-inspect');
var retext = new Retext()
.use(inspect)
.use(visit);
/*
* See each function signature below.
*/
retext.parse('A simple English sentence.', function (err, tree) {
if (err) throw err;
/* Visit every node in the first sentence. */
tree.head.head.visit(function (node) {
console.log(node);
});
/*
* Logs:
*
* WordNode[1]
* └─ TextNode: 'A'
* TextNode: 'A'
* WhiteSpaceNode[1]
* └─ TextNode: ' '
* TextNode: ' '
* WordNode[1]
* └─ TextNode: 'simple'
* TextNode: 'simple'
* WhiteSpaceNode[1]
* └─ TextNode: ' '
* TextNode: ' '
* WordNode[1]
* └─ TextNode: 'English'
* TextNode: 'English'
* WhiteSpaceNode[1]
* └─ TextNode: ' '
* TextNode: ' '
* WordNode[1]
* └─ TextNode: 'sentence'
* TextNode: 'sentence'
* PunctuationNode[1]
* └─ TextNode: '.'
* TextNode: '.'
*/
});
Invoke callback
for every descendant of the operated on context.
Parameters:
callback
(function(Node): boolean?
): Visitor. Stops visiting when it returns false
.retext.parse('A simple English sentence.', function (err, tree) {
if (err) throw err;
/* Visit every word node. */
tree.visit(tree.WORD_NODE, function (node) {
console.log(node);
});
/*
* WordNode[1]
* └─ TextNode: 'A'
* WordNode[1]
* └─ TextNode: 'simple'
* WordNode[1]
* └─ TextNode: 'English'
* WordNode[1]
* └─ TextNode: 'sentence'
*/
});
Invoke callback
for every descendant of the context of type
.
Parameters:
type
: Type of visited nodes.callback
(function(Node): boolean?
): Visitor. Stops visiting when the return value is false
.On a MacBook Air.
Visit every node
7,806 op/s » A section
670 op/s » An article
Visit every word node
6,249 op/s » A section
521 op/s » An article
FAQs
Deprecated
The npm package retext-visit receives a total of 1 weekly downloads. As such, retext-visit popularity was classified as not popular.
We found that retext-visit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.